<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@include file="/context/mytags.jsp" %>
<t:base type="jquery,easyui,tools,DatePicker"></t:base>
<script type="text/javascript" src="plug-in/date/xdate.js"></script>
<script type="text/javascript">



    $(function () {
        mallOrderReportModule.init();
    });
    var mallOrderReportModule = (function () {

        /*初始化时间查询*/
        var initDate = function () {
            $("input[name='orderCreateTime_begin']").attr("class", "Wdate").click(function () {
                WdatePicker({dateFmt: 'yyyy-MM-dd'});
            });
            $("input[name='orderCreateTime_end']").attr("class", "Wdate").click(function () {
                WdatePicker({dateFmt: 'yyyy-MM-dd'});
            });
            $("input[name='orderFinishTime_begin']").attr("class", "Wdate").click(function () {
                WdatePicker({dateFmt: 'yyyy-MM-dd'});
            });
            $("input[name='orderFinishTime_end']").attr("class", "Wdate").click(function () {
                WdatePicker({dateFmt: 'yyyy-MM-dd'});
            });

            /*   var nowTime = new Date();
             startTime = new Date(nowTime);
             startTime.setMonth(nowTime.getMonth() - 1);
             var first = new XDate(startTime).toString('yyyy-MM-dd');
             var end = new XDate(nowTime).toString('yyyy-MM-dd');
             $("input[name='orderCreateTime_begin']").val(first);
             $("input[name='orderCreateTime_end']").val(end);
             $("input[name='orderFinishTime_begin']").val(first);
             $("input[name='orderFinishTime_end']").val(end);*/
        }


        /**
         * 订单类型改变事件
         */
        var orderTypeCharge = function () {
            var orderStatusHtml = '<option value="" selected="selected">---请选择---</option>';
            $("select[name='orderStatus']").html(orderStatusHtml);
            $("select[name='orderType']").bind("change", function () {
                var orderType = $(this).val();
                if (null != orderType && "" != orderType && typeof (orderType) != "undefined") {
                    orderType = parseInt(orderType);
                    switch (orderType) {
                        case 0:
                            orderStatusHtml += '<option ordertype="0" value="1"> 等待付款 </option>' +
                                    '<option ordertype="0" value="2"> 已支付 </option>' +
                                    '<option ordertype="0" value="3"> 已发货 </option>' +
                                    '<option ordertype="0" value="4"> 退款中 </option>' +
                                    '<option ordertype="0" value="5"> 交易完成 </option>' +
                                    '<option ordertype="0" value="6"> 已结算 </option>' +
                                    '<option ordertype="0" value="99"> 交易关闭 </option>' +
                                    '<option ordertype="0" value="98"> 支付未完成 </option>';
                            break;
                        case 1:
                            orderStatusHtml += '<option ordertype="1" value="1"> 等待付款 </option>' +
                                    '<option ordertype="1" value="2"> 已支付 </option>' +
                                    '<option ordertype="1" value="4"> 退款中 </option>' +
                                    '<option ordertype="1" value="5"> 交易完成 </option>' +
                                    '<option ordertype="1" value="6"> 已结算 </option>' +
                                    '<option ordertype="1" value="99"> 交易关闭 </option>' +
                                    '<option ordertype="1" value="98"> 支付未完成 </option>';
                            break;
                        case 2:
                            orderStatusHtml += '<option ordertype="2" value="1"> 等待付款 </option>' +
                                    '<option ordertype="2" value="2"> 已支付 </option>' +
                                    '<option ordertype="2" value="4"> 退款中 </option>' +
                                    '<option ordertype="2" value="5"> 交易完成 </option>' +
                                    '<option ordertype="2" value="6"> 已结算 </option>' +
                                    '<option ordertype="2" value="99"> 交易关闭 </option>' +
                                    '<option ordertype="2" value="98"> 支付未完成 </option>';
                            break;
                    }
                }
                $("select[name='orderStatus']").html("");
                $("select[name='orderStatus']").html(orderStatusHtml);
                orderStatusHtml = '<option value="" selected="selected">---请选择---</option>';
            });
        }

        //重写查询方法
        var search = function(){

            var searchDom = $("a[iconcls='icon-search']");
            searchDom.removeAttr('onclick');
            searchDom.bind("click", function(){
                mallOrderReportListsearch();
            });
        }

        //重写查询方法
        var  mallOrderReportListsearch = function(){
            if ($("#mallOrderReportListForm").Validform({tiptype: 3}).check()) {
                //判断油卡卡号，车主姓名，项目名
                var cardNo = $("input[name='cardNo']").val();
                var vehicleName = $("input[name='vehicleName']").val();
                var projectName = $("input[name='projectName']").val();
                if( (cardNo != null && cardNo != '' && typeof(cardNo) != 'undefined' )
                        || (vehicleName != null && vehicleName != '' && typeof(vehicleName) != 'undefined' )
                        || (projectName != null && projectName != '' && typeof(projectName) != 'undefined' ) ){
                    $("select[name='orderType']").val(2);
                }
                var queryParams = $('#mallOrderReportList').datagrid('options').queryParams;
                $('#mallOrderReportListtb').find('*').each(function () {
                    queryParams[$(this).attr('name')] = $(this).val();
                });
                $('#mallOrderReportList').datagrid({
                    url: 'mallReportController.do?orderReportListDatagrid&field=id,orderNo,orderType,orderStatusName,orderStatus,settlementStatus,sellerName,shopName,productCode,productName,cardNo,amount,price,totalMoney,actualPayMoney,subsidyMoney,subsidyTypeName,vehicleName,vehiclePhoneNum,projectName,buyerName,userName,orderCreateTime,orderCreateTime_begin,orderCreateTime_end,orderFinishTime,orderFinishTime_begin,orderFinishTime_end,payTime,expressTime,confirmTime,confirmTime_begin,confirmTime_end,offlineStoreName,settlementDay,settlementTime,settlementMoney,orderMoney,settlementExpenses,settlementExpensesAdvance,applyUserName,applyTime,settlementUserName,settlementTime1,',
                    pageNumber: 1
                });
            }
        }

        var module = {
            init: function () {
                initDate();
                orderTypeCharge();
                search();
                $("a[iconcls='icon-search']").removeAttr('onclick');
            },

            //导出文件
            exportFile: function () {
                window.location.href = 'mallReportController.do?orderReportExport&' + $("#mallOrderReportListForm").serialize();
            }

        }
        return module;
    })();
</script>
<div class="easyui-layout" fit="true">
    <div region="center" style="padding:0px;border:0px">
        <t:datagrid name="mallOrderReportList" title="商城订单报表" actionUrl="mallReportController.do?orderReportListDatagrid" idField="id" fit="true" queryMode="group">
            <t:dgCol title="编号" field="id" hidden="true"></t:dgCol>
            <t:dgCol title="订单号" field="orderNo" query="true"></t:dgCol>
            <t:dgCol title="订单类型" field="orderType" query="true" replace="线上商城订单_0,本地服务订单_1,在线充值服务订单_2"></t:dgCol>
            <t:dgCol title="订单状态" field="orderStatusName"></t:dgCol>
            <t:dgCol title="订单状态" field="orderStatus" hidden="true" query="true" replace="1_0"></t:dgCol>
            <t:dgCol title="结算状态" field="settlementStatus" query="true" replace="未结算_0,已结算_1"></t:dgCol>
            <t:dgCol title="商家名称" field="sellerName" query="true"></t:dgCol>
            <t:dgCol title="店铺名称" field="shopName" query="true"></t:dgCol>
            <t:dgCol title="商品编码" field="productCode"></t:dgCol>
            <t:dgCol title="商品名称" field="productName"></t:dgCol>
            <t:dgCol title="充值卡号" field="cardNo" query="true"></t:dgCol>
            <t:dgCol title="数量" field="amount"></t:dgCol>
            <t:dgCol title="单价" field="price"></t:dgCol>
            <t:dgCol title="交易金额" field="totalMoney"></t:dgCol>
            <t:dgCol title="买家实付款" field="actualPayMoney"></t:dgCol>
            <t:dgCol title="平台补贴金额" field="subsidyMoney"></t:dgCol>
            <t:dgCol title="平台补贴类型" field="subsidyTypeName"></t:dgCol>
            <t:dgCol title="车主姓名" field="vehicleName" query="true"></t:dgCol>
            <t:dgCol title="车主电话" field="vehiclePhoneNum"></t:dgCol>
            <t:dgCol title="项目名" field="projectName" query="true"></t:dgCol>
            <t:dgCol title="买家" field="buyerName" query="true"></t:dgCol>
            <t:dgCol title="用户名" field="userName" query="true"></t:dgCol>
            <t:dgCol title="下单时间" field="orderCreateTime" formatter="yyyy-MM-dd hh:mm:ss" query="true" queryMode="group"></t:dgCol>
            <t:dgCol title="交易完成时间" field="orderFinishTime" formatter="yyyy-MM-dd hh:mm:ss" hidden="true" query="true" queryMode="group"></t:dgCol>
            <t:dgCol title="支付时间" field="payTime" formatter="yyyy-MM-dd hh:mm:ss"></t:dgCol>
            <t:dgCol title="发货时间" field="expressTime" formatter="yyyy-MM-dd hh:mm:ss"></t:dgCol>
            <t:dgCol title="交易完成时间" field="confirmTime" formatter="yyyy-MM-dd hh:mm:ss" queryMode="group"></t:dgCol>
            <t:dgCol title="消费实体店" field="offlineStoreName"></t:dgCol>
            <t:dgCol title="账单周期" field="settlementDay"></t:dgCol>
            <t:dgCol title="可结算日期" field="settlementTime" formatter="yyyy-MM-dd hh:mm:ss"></t:dgCol>
            <t:dgCol title="结算金额" field="settlementMoney"></t:dgCol>
            <t:dgCol title="交易总金额" field="orderMoney"></t:dgCol>
            <t:dgCol title="交易服务费" field="settlementExpenses"></t:dgCol>
            <t:dgCol title="提前结算服务费" field="settlementExpensesAdvance"></t:dgCol>
            <t:dgCol title="申请结算人" field="applyUserName"></t:dgCol>
            <t:dgCol title="申请结算日期" field="applyTime" formatter="yyyy-MM-dd hh:mm:ss"></t:dgCol>
            <t:dgCol title="结算人" field="settlementUserName"></t:dgCol>
            <t:dgCol title="结算日期" field="settlementTime1" formatter="yyyy-MM-dd hh:mm:ss"></t:dgCol>
            <t:dgToolBar operationCode="export" title="导出" icon="icon-putout" funname="mallOrderReportModule.exportFile"></t:dgToolBar>
        </t:datagrid>
    </div>
</div>